/**
 * Copyright (c) 2010, Todd Ginsberg
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * Neither the name of Todd Ginsberg, or Gowalla nor the
 *      names of any contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 *  Also, please use this for Good and not Evil.  
 */
package com.ginsberg.gowalla.dto.problems;

import java.io.Serializable;

import com.ginsberg.gowalla.dto.Id;
import com.ginsberg.gowalla.dto.Spot;

/**
 * Encapsulates a Problem to be reported about a spot.  
 * Please see ProblemFactory for creating these.
 * 
 * @author Todd Ginsberg
 */
public class ProblemReport implements Serializable {

	/**
	 * Defines the types of Problems Gowalla is willing to listen to.
	 *
	 * @author Todd Ginsberg
	 */
	public enum Type {
		/**
		 * The Spot is inappropriate, fake, or otherwise shouldn't exist 
		 */
		INVALID,
		/**
		 * Another entry for this Spot exists with another name and location 
		 */
		DUPLICATE,
		/**
		 * The Spot's location is incorrect 
		 */
		MISLOCATED,
		/**
		 * The business or event that is represented by the Spot is closed or has expired 
		 */
		VENUE_CLOSED,
		/**
		 * Some detail about the Spot, like name, phone number, or address is incorrect or missing 
		 */
		INACCURATE_INFORMATION
	};

	private static final long serialVersionUID = -704481289035056281L;
	private int spotId;
	private String description;
	private Type type;
	

	/**
	 * Constructor!
	 */
	protected ProblemReport(final Type type, int spotId, final String description) {
		super();
		this.spotId = spotId;
		this.description = description;
		this.type = type;
	}

	/**
	 * @return the spotId
	 */
	public int getSpotId() {
		return spotId;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @return the type
	 */
	public Type getType() {
		return type;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((description == null) ? 0 : description.hashCode());
		result = prime * result + spotId;
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProblemReport other = (ProblemReport) obj;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (spotId != other.spotId)
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return String.format("ProblemReport [spotId=%s, type=%s, description=%s]", spotId, type, description);
	}

}
